package cn.concurrence.juc;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

/**
 * @author summit
 * @since 2022/4/24 14:36
 */
public class CyclicBarrierTest {


	public static void main(String[] args) {
		CyclicBarrier cb = new CyclicBarrier(7,()->{
			System.out.println("集齐七龙珠");
		});

		for (int i = 0; i < 7; i++) {
			new Thread(() -> {

				try {
					cb.await();
				} catch (InterruptedException e) {
					e.printStackTrace();
				} catch (BrokenBarrierException e) {
					e.printStackTrace();
				}
			}).start();
		}
	}
}
